﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataAccess;
using EnglishLibrary;

namespace DataTransfer
{
    /// <summary>
    /// Transfer the data from the dataaccess object to the UI and vice versa
    /// </summary>
    public class VocabularyDT
    {
        //The object for invoking methods
        private VocabularyDAO vocabularyDAO;

        public VocabularyDT()
        {
            vocabularyDAO = new VocabularyDAO();
        }

        public VocabularyDT(string filePath)
        {
            vocabularyDAO = new VocabularyDAO(filePath);
        }

        /// <summary>
        /// Get all the vocabularies in the database
        /// </summary>
        /// <returns>List of vocabularies</returns>
        public List<Vocabulary> GetListVocabulary(bool isGetDeleted)
        {
            return vocabularyDAO.GetListItems(isGetDeleted);
        }

        /// <summary>
        /// Insert a new vocabulary into the database
        /// </summary>
        /// <param name="vocabularyItem">the vocabulary item to insert</param>
        /// <returns>true if success or false if failure</returns>
        public bool InsertVocabulary(Vocabulary vocabularyItem)
        {
            return vocabularyDAO.InsertItem(vocabularyItem);
        }

        /// <summary>
        /// Update a vocabulary
        /// </summary>
        /// <param name="vocabularyItem">the object which holds the infor</param>
        /// <returns>true if success, false if failure</returns>
        public bool UpdateVocabulary(Vocabulary vocabularyItem)
        {
            return vocabularyDAO.UpdateItem(vocabularyItem);
        }

        /// <summary>
        /// Get the items created before date
        /// </summary>
        /// <param name="date">the date to compare</param>
        /// <returns>results</returns>
        public List<Vocabulary> GetItemsBeforeDate(DateTime date)
        {
            return vocabularyDAO.GetItemsBeforeDate(date);
        }

        /// <summary>
        /// Get the items created after date
        /// </summary>
        /// <param name="date">the date to compare</param>
        /// <returns>results</returns>
        public List<Vocabulary> GetItemsAfterDate(DateTime date)
        {
            return vocabularyDAO.GetItemsAfterDate(date);
        }

        /// <summary>
        /// Get the items by cateid
        /// </summary>
        /// <param name="date">the cate id list to get</param>
        /// <returns>results</returns>
        public List<Vocabulary> GetItemsByCates(List<int> catesId)
        {
            return vocabularyDAO.GetItemsByCates(catesId);
        }

        /// <summary>
        /// Delete a Vocabulary
        /// </summary>
        /// <param name="vocabularyId">the id of the vocabulary deleted</param>
        /// <returns>true if success, false if failure</returns>
        public bool DeleteVocabulary(int vocabularyId)
        {
            return vocabularyDAO.DeleteItem(vocabularyId);
        }

        public string FilePath
        {
            get { return vocabularyDAO.FilePath; }
            set { vocabularyDAO.FilePath = value; }
        }
    }
}
